package com.etc.yzrnx.library.service.impl;

import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;

import javax.swing.table.AbstractTableModel;

import com.etc.yzrnx.library.bean.Borrow_bookinfo;

public class BorrowInfoPageTableModel extends AbstractTableModel {

	public Vector columnHeaders;
	public Vector tableData;
	private String[] names = new String[]{
			"\u8BFB\u8005\u7F16\u53F7", "\u8BFB\u8005\u59D3\u540D", 
			"\u4E66\u672C\u7F16\u53F7", "\u4E66\u540D", 
			"\u501F\u9605\u65F6\u95F4", "\u8FD8\u4E66\u65F6\u95F4", 
			"\u62D6\u6B20\u65F6\u95F4\uFF08\u5929\uFF09", 
			"\u7F5A\u6B3E\uFF08\u5143\uFF09"				
			};
	
	public int i;
	List<Borrow_bookinfo> bookinfos =new ArrayList<>();
	public BorrowInfoPageTableModel(ResultSet rset )throws SQLException
	{
		Vector rowData;
		ResultSetMetaData rsmd=rset.getMetaData();
		int count=rsmd.getColumnCount();
		columnHeaders=new Vector(count);
		tableData=new Vector();
		for(i=1;i<=count;i++)
		{
			columnHeaders.addElement(names[i-1]); 
		}
		while(rset.next())
		{
			rowData=new Vector(count);
			for(i=1;i<=count;i++)
			{ 
				rowData.addElement(rset.getObject(i));
			}
			tableData.addElement(rowData);
		}
		}
	public int getColumnCount()
	{ 
		return columnHeaders.size(); 
	}
	public int getRowCount()
	{ 
		return tableData.size(); 
	}
	public Object getValueAt(int row,int column)
	{
		Vector rowData=(Vector)(tableData.elementAt(row));
		return rowData.elementAt(column);
	}
	public boolean isCellEditable(int row,int column)
	{ return false; }
	
	public String getColumnName(int column)
	{ 
		return (String)(columnHeaders.elementAt(column)); 
	}
}
